#include "InputManager.h"
#include <iostream>
using namespace EPOC;
InputManager* g_inputManager = NULL;
InputManager::InputManager(void)
{
	g_inputManager = this;
	

	for(int i = 0; i < 322; i++)
	{
		m_prevKeyState[i] = m_keyState[i] =false;
	}

}


InputManager::~InputManager(void)
{
}

void InputManager::Update(SDL_Event* sdlInputEvent)
{
	switch (sdlInputEvent->type)
	{
	case SDL_KEYDOWN:
		m_keyState[sdlInputEvent->key.keysym.scancode] = true;
		break;
	case SDL_KEYUP:
		m_keyState[sdlInputEvent->key.keysym.scancode] = false;
		

	default:
		break;
	}

}

bool InputManager::IsKeyDown(EPKey key)
{
	//m_keyState = SDL_GetKeyState(NULL);
	
	return m_keyState[key] == 1;
}

bool InputManager::IsKeyPressed(EPKey key)
{
	
	if(m_prevKeyState[key] != m_keyState[key] )
	{
		m_prevKeyState[key] = !m_prevKeyState[key];
		return m_prevKeyState[key];
	}
	else
		return false;
}
